package cn.sinata.wanglin.mine.activity;
import android.view.View;
import android.widget.TextView;

import com.xilada.xldutils.activitys.TitleActivity;
import com.xilada.xldutils.utils.SharedPreferencesUtils;

import butterknife.BindView;
import butterknife.OnClick;
import cn.sinata.wanglin.R;
import cn.sinata.wanglin.commonutils.Constant;

public class NotifcationActivity extends TitleActivity {
    @BindView(R.id.tv_voice)
    TextView tv_voice ;//声音
    @BindView(R.id.tv_shock)
    TextView tv_shock ;//震动
    @BindView(R.id.tv_notifyallowed)
    TextView tv_notifyallowed ;//消息通知

    @Override
    protected int setContentId() {
        return R.layout.activity_notifcation;
    }

    @Override
    protected void initView() {
        super.initView();
        setTitle("通知设置");
        boolean selectedVoice= SharedPreferencesUtils.getBoolean(Constant.SP_VOICE,true);
        boolean selectedShock= SharedPreferencesUtils.getBoolean(Constant.SP_SHOCK,true);
        boolean selectednotify= SharedPreferencesUtils.getBoolean(Constant.SP_NOTIFY_ALLOWED,true);
        tv_voice.setSelected(selectedVoice);
        tv_shock.setSelected(selectedShock);
        tv_notifyallowed.setSelected(selectednotify);
    }
    @OnClick({R.id.tv_voice,R.id.tv_shock,R.id.tv_notifyallowed})
    void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_voice:
                //描述:声音
                boolean selected= tv_voice.isSelected();
                tv_voice.setSelected(!selected);
                SharedPreferencesUtils.save(Constant.SP_VOICE,!selected);
                break;
            case R.id.tv_shock:
                //描述:震动
                boolean selectedShock= tv_shock.isSelected();
                tv_shock.setSelected(!selectedShock);
                SharedPreferencesUtils.save(Constant.SP_SHOCK,!selectedShock);
                break;
            case R.id.tv_notifyallowed:
                //描述:新消息通知
                boolean selectednotify= tv_notifyallowed.isSelected();
                tv_notifyallowed.setSelected(!selectednotify);
                SharedPreferencesUtils.save(Constant.SP_NOTIFY_ALLOWED,!selectednotify);
                break;

        }
    }
}
